﻿#include "DANodeLinkPoint.h"

DANodeLinkPoint::DANodeLinkPoint() : direction(East), way(Output) {}

DANodeLinkPoint::DANodeLinkPoint(const QPoint &p, const QString &n, DANodeLinkPoint::Way w, DANodeLinkPoint::Direction d)
    : position(p), name(n), way(w), direction(d)
{
}

bool DANodeLinkPoint::isValid() const
{
    return (!name.isNull());
}

bool DANodeLinkPoint::isInput() const
{
    return (this->way == Input);
}

bool DANodeLinkPoint::isOutput() const
{
    return (this->way == Output);
}

/**
 * @brief FCNodeLinkPoint 的等于号操作符
 * @param a
 * @param b
 * @return
 */
bool operator==(const DANodeLinkPoint &a, const DANodeLinkPoint &b)
{
    return ((a.name == b.name) && (a.direction == b.direction) && (a.position == b.position) && (a.way == b.way));
}

bool operator==(const DANodeLinkPoint &a, const QString &b)
{
    return (a.name == b);
}

bool operator<(const DANodeLinkPoint &a, const DANodeLinkPoint &b)
{
    return (a.name < b.name);
}

uint qHash(const DANodeLinkPoint &key, uint seed)
{
    return (qHash(key.name, seed));
}

QDebug operator<<(QDebug dbg, const DANodeLinkPoint &a)
{
    dbg.nospace() << "(" << a.name << ") [" << a.position << "],way is " << a.way << ",direct is " << a.direction;
    return (dbg.space());
}
